package com.it2297.model;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;

import com.it2297.main.App;

public class ShoppingCart {

	private int orderID;
	private Date OrderDate;
	private String p_id;
	private double price;
	private int quantity;
	public int getOrderID() {
		return orderID;
	}
	public void setOrderID(int orderID) {
		this.orderID = orderID;
	}
	public Date getOrderDate() {
		return OrderDate;
	}
	public void setOrderDate(Date orderDate) {
		OrderDate = orderDate;
	}
	public String getP_id() {
		return p_id;
	}
	public void setP_id(String p_id) {
		this.p_id = p_id;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public int getQuantity() {
		return quantity;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	
	public static ArrayList<ShoppingCart> tempShoppingCart(String product_id, double price, int quantity){
		ArrayList<ShoppingCart> temp_list = new  ArrayList<ShoppingCart>();
		ShoppingCart sc = new ShoppingCart();
		sc.setP_id(product_id);
		sc.setPrice(price);
		sc.setQuantity(quantity);
		
		temp_list.add(sc);
		
		return temp_list;
	}
	/*public static ArrayList<ShoppingCart> getShopping(){
		
	}
	
	
	
	public static ArrayList<ShoppingCart> getShoppingCart(int order_id){

		
		ArrayList<ShoppingCart> store = new ArrayList<ShoppingCart>();
		try {
			App.mySqlConnection.open();
			String sql = "SELECT * FROM americano.SHOPPING_CART_VIEW WHERE order_id = '" + order_id + "' AND status = 'unpaid'";
			ResultSet rs = App.mySqlConnection.executeQuery(sql);
			while(rs.next()){
				ShoppingCart sc = new ShoppingCart();
				sc.setOrderDate(rs.getDate("date_order"));
				sc.setP_name(rs.getString("prodname"));
				sc.setPrice(rs.getDouble("price"));
				sc.setQuantity(rs.getInt("quantity"));
				store.add(sc);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			App.mySqlConnection.close();
		}
		return store;
	}
	
	//String product_name, int order_id
	
	public static void addShoppingCart(String product_name, int order_id, double price, int quantity , int product_id, String nric, int i, String status, String name){
		Date date = new Date(new java.util.Date().getTime());
		try {
			App.mySqlConnection.open();
			String sql = "INSERT INTO americano.SHOPPING_CART_VIEW(quantity, product_id, prodname, price , order_id , date_order ,fk_customer_nric, amount , status, name )";
			sql += "VALUES '" + quantity + "','" + product_id + "','" + product_name + "','" + price + "','" + order_id + "','" + date + "','" + nric + "','" + i + "','" + status + "','" + name + "'" ;
			App.mySqlConnection.executeUpdate(sql);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			App.mySqlConnection.close();
		}
		
		
		
		
		
		
		
	}
	*/
	
}
